﻿SmitearWebGL.Core.ReferenceCounter = Class.extend(
{
	/******** constructor ********/
	
	init : function()
	{
		this._nReferenceCount = 0;
		this._registClass( "SmitearWebGL.Core.ReferenceCounter" );
	}
	,
	
	/******** public method ********/
	
	addRef : function()
	{
		$THROW( this._nReferenceCount != Math.floor(Number.MAX_VALUE), "引用计数超过最大值" );
		return ++ this._nReferenceCount;
	}
	,
	release : function()
	{
		$THROW( this._nReferenceCount > 0, "引用计数为零" );
		return -- this._nReferenceCount;
	}
	,
	getReferenceCount : function()
	{
		return this._nReferenceCount;
	}
}
);